package cc.lj.internal.merchant.infrastructure.repository.mysql;

import cc.lj.internal.core.exception.ServiceException;
import cc.lj.internal.core.model.BasePageHelper;
import cc.lj.internal.merchant.domain.contract.repository.IMerchantContractObjectsRepository;
import cc.lj.internal.merchant.infrastructure.dao.IMerchantContractObjectsMapper;
import cc.lj.internal.merchant.infrastructure.exception.MerchantExceptionEnum;
import cc.lj.internal.merchant.infrastructure.po.MerchantContractObjectsPO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 合同相关各收费项目表　Mysql仓储实现
 * @author liangxifeng
 * @date 2021-12-24
 */
@Repository("merchantContractObjectsMysqlRespository")
public class MerchantContractObjectsMysqlRespository implements IMerchantContractObjectsRepository, BasePageHelper<MerchantContractObjectsPO> {
    @Autowired
    private IMerchantContractObjectsMapper objectsMapper;


    @Override
    public List<MerchantContractObjectsPO> list(MerchantContractObjectsPO param) {
        QueryWrapper<MerchantContractObjectsPO> wrapper = new QueryWrapper<>(param);
        List<MerchantContractObjectsPO> entitys = objectsMapper.selectList(wrapper);
        if(entitys == null)
        {
            throw new ServiceException(MerchantExceptionEnum.MERCHANT_CONTRACT_OBJECTS_LIST_NULL);
        }
        return entitys;
    }

    @Override
    public List<MerchantContractObjectsPO> getList(MerchantContractObjectsPO entityPO) {
        return list(entityPO);
    }
}
